package com.cheneyjoo.servlets;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cheneyjoo.controller.ClassStudentsController;
import com.cheneyjoo.model.STUDENT;
import com.cheneyjoo.tools.AjaxJsonDataHelper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "NoClassStudentServlet",urlPatterns = "/noclassstudent")
public class NoClassStudentServlet extends HttpServlet {
    private static final long serialVersionUID = -7321955016085355914L;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");
        ClassStudentsController stu=new ClassStudentsController();
        List<STUDENT> studentList= stu.getNoClassStudents();
        PrintWriter out = response.getWriter();
        out.print(JSON.toJSON(studentList));
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
